﻿using Android.App;
using Android.Content.PM;
using Android.OS;
using AndroidX.Core.View;

namespace Tennis;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{

    public static MauiAppCompatActivity MainActivityInstance = null;
    protected override void OnCreate(Bundle savedInstanceState)
    {
        //全屏，即隐藏状态栏，时间、信号这些也不可见
        // Window.SetFlags(Android.Views.WindowManagerFlags.Fullscreen, Android.Views.WindowManagerFlags.Fullscreen);

        //半透明 任务栏
        // Window.SetFlags(Android.Views.WindowManagerFlags.TranslucentStatus, Android.Views.WindowManagerFlags.TranslucentStatus);

        //全透明任务栏
        Window.SetFlags(Android.Views.WindowManagerFlags.TranslucentNavigation, Android.Views.WindowManagerFlags.TranslucentNavigation);



        //设置状态栏、导航栏色颜色为透明
        // Window.SetTitleColor(Android.Graphics.Color.Red);



        //var uiOpts = SystemUiFlags.LayoutStable | SystemUiFlags.LayoutFullscreen | SystemUiFlags.LightStatusBar;
        ////LayoutStable表示布局稳定，不随其他变动而变动
        ////LayoutFullscreen表示把布局拓宽到全屏幕




        //Window.SetStatusBarColor(new Android.Graphics.Color(255, 123, 14));
        Window.SetStatusBarColor(Android.Graphics.Color.Transparent);
        Window.SetNavigationBarColor(Android.Graphics.Color.Transparent);


        MainActivityInstance = this;
        SetStatusBarLight(true);

        base.OnCreate(savedInstanceState);
    }


    public static void SetStatusBarLight(bool isLight)
    {
        if (MainActivityInstance != null)
        {
            WindowInsetsControllerCompat windowInsetsController =
            new WindowInsetsControllerCompat(MainActivityInstance.Window, MainActivityInstance.Window.DecorView);
            windowInsetsController.AppearanceLightStatusBars = isLight;
        }
    }

}
